<script type="text/javascript">


    $(document).ready(function(){
        

        //$("#id").autoNumeric({aSep: '.', aDec: ','});

    
        $("#btn_pilih_lokasi").click(function(){
            //alert('aaa');
            $("#dialog-lokasi").dialog('open');
        });

        $("#nop1").keyup(function(e){
            if (e.keyCode == '113'){
                $("#dialog-objek").dialog("open");
            }		
        });
        $("#subjek_pajak_id").keyup(function(e){
            if (e.keyCode == '114'){
                $("#dialog-nik").dialog('open');
            }		
        });

        $("#btn_pilih_Nik").click(function(){
            $("#dialog-nik").dialog('open');
        });


        });
        
//        function PilihLokasi(aa){
//            $("#kode_png").val(kode_png);
//            $("#nama_png").val(nama_png);
//
//            $("#dialog-lokasi").dialog('close');
//        }

  

        function PilihLokasi(aa){
            var cc=aa.split("#");
            
            $("#kode_png").val(cc[0]);
            $("#nama_png").val(cc[1]);
            
            $("#dialog-lokasi").dialog('close');
        }


</script>

<?php
if (Yii::app()->user->hasFlash('success'))
    $this->widget('bootstrap.widgets.TbAlert', array());

$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'id' => 'horizontalForm',
    'type' => 'horizontal',
    'enableAjaxValidation' => false,
        ));
?>
<div class="form">


    <?php echo $form->errorSummary($model); ?>
    <div class="control-group ">
        <label class="control-label" >Kode KIB</label>
        <div class="controls">

            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span1', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>

    <div class="control-group ">
        <label class="control-label" >Kode Lokasi</label>
        <div class="controls">
            <div class="span3" style="margin-left:0;">
                <div class="input-group">
                    <?php echo $form->textField($model, 'kode_aset', array('class' => 'form-control', 'id' => 'kode_png', 'maxlength' => 20)); ?>
                    <span class="input-group-btn">	
                        <?php
                        $this->widget('bootstrap.widgets.TbButton', array(
                            'type' => 'info',
                            'label' => 'F1',
                            'htmlOptions' => array('id' => 'btn_pilih_lokasi')
                        ));
                        ?>
                    </span>
                </div>
            </div>
        </div>
    </div>

    <div class="control-group ">
        <label class="control-label"></label>
        <div class="controls">
            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span4', 'id' => 'nama_png', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>

</div>
    <div class="control-group ">
        <label class="control-label" ><b>Kode Barang</b></label>
        <div class="controls">
            <div class="span3" style="margin-left:0;">
                <div class="input-group">
                    <?php echo $form->textField($model, 'kode_aset', array('class' => 'form-control', 'id' => 'no_rev', 'maxlength' => 25)); ?>
                    <span class="input-group-btn">	
                        <?php
                        $this->widget('bootstrap.widgets.TbButton', array(
                            'type' => 'info',
                            'label' => 'F2',
                            'htmlOptions' => array(
                                'id' => 'btn_pilih_lokasi2',
                                'style' => 'padding-left:15px;',
                            )
                        ));
                        ?>
                    </span>
                </div>
            </div>
        </div>
    </div>

<div class="control-group ">
        <label class="control-label" >Nama Barang</label>
        <div class="controls">

            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span4', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>

<div class="control-group ">
        <label class="control-label" >No Reg</label>
        <div class="controls">

            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span2', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>

<div class="control-group ">
        <label class="control-label" >Luas (M2)</label>
        <div class="controls">
            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span3', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        Tahun Pengadaan
        <?php echo $form->textField($model, 'kode_aset', array('class' => 'span1', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>

<div class="control-group ">
        <label class="control-label" >Alamat</label>
        <div class="controls">

            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span2', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>

<div class="control-group ">
        <label class="control-label" >Status Hak</label>
        <div class="controls">

            <?php echo $form->textArea($model, 'kode_aset', array('class' => 'span4', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>

<div class="control-group ">
        <label class="control-label" >Sertifikat Tgl</label>
        <div class="controls">
				<div class="span2" style="margin:0;">
					<div class="input-group">
					<span class="input-group-addon"><i class="icon-calendar"></i></span>
					<?php
					$this->widget('zii.widgets.jui.CJuiDatePicker', array(
						'model' => $model,
						'attribute' => 'kode_aset',
                                            //'attribute' => 'tgl_sertif',
                                            // additional javascript options for the date picker plugin
						'options' => array(
							'yearRange' => 'c-50:c+20',
						),
					));
					?>
					</div>
				</div>	
    </div>
<div class="control-group ">
        <label class="control-label" >Sertf.No</label>
        <div class="controls">

            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span2', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>

<div class="control-group ">
        <label class="control-label" >Pengguna</label>
        <div class="controls">
            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span4', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>

<div class="control-group ">
        <label class="control-label" >Asal</label>
        <div class="controls">
            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span4', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>
<div class="control-group ">
        <label class="control-label" >Harga Perolehan</label>
        <div class="controls">
            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span2', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>

<div class="control-group ">
        <label class="control-label" >Harga Pasar</label>
        <div class="controls">
            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span2', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>

<div class="control-group ">
        <label class="control-label" >Daftar Harga</label>
        <div class="controls">
            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span2', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
            Tahun Nilai
            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span2', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>

<div class="control-group ">
        <label class="control-label" >Kondisi</label>
        <div class="controls">
            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span2', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>
<div class="control-group ">
        <label class="control-label">Keterangan</label>
        <div class="controls">
            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span4', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>
<div class="control-group ">
        <label class="control-label" >Kode Milik</label>
        <div class="controls">
            <?php echo $form->textField($model, 'kode_aset', array('class' => 'span2', 'id' => 'kode', 'readonly' => true, 'maxlength' => 50)); ?>
        </div>
    </div>

<div class="form-actions">
    <?php
    $this->widget('bootstrap.widgets.TbButton', array(
        'buttonType' => 'submit',
        'type' => 'primary',
        'label' => $model->isNewRecord ? 'Create' : 'Save',
    ));
    ?>

<?php $this->endWidget(); ?>
</div>


<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
    'id' => 'dialog-lokasi',
    'options' => array(
        'title' => 'Cari Data Lokasi',
        'overflow' => 'scroll',
        'width' => 900,
        'height' => 500,
        'autoOpen' => false,
    //'buttons' => array(
    //    'Ok' => 'js:function(){$(this).dialog("close")}',),
    ),
));
?>

<?php 
		Yii::app()->clientScript->registerScript('pengelola', "
			$('form#pengelola').submit(function(){
				$.fn.yiiGridView.update('Pengelola', {
					data: $(this).serialize()
				});
				return false;
			});
		
		");
                

?>
        
<form method="get" class="form-horizontal" action="<?php echo Yii::app()->createUrl($this->route); ?>" id="pengelola">
	<div class="alert alert-info">
		<div class="control-group">
			<label class="control-label">Kode Lokasi </label>
			<div class="controls">
				<input type="text" class="span3" name="Pengelola[kode_png]" id="pengelola_kode_png" /> 
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">Nama Lokasi </label>
			<div class="controls">    
				<input type="text" class="span3" name="Pengelola[nama_png]" id="pengelola_nama_png" />
			<!--button class="btn btn-primary" id="btn_search" type="submit" name="btn_search">Cari</button-->
			</div>
		</div>
		
		<?php
		$this->widget('bootstrap.widgets.TbButton', array(
			'buttonType' => 'submit',
			//'type' => 'primary',
			'icon' => 'search',
			'htmlOptions' => array(
				'id' => 'btn_search',
				'style' => 'margin-left:20px;',
			),
			'label' => 'Cari',
		));
		?>
	</div>
</form>



<?php
$this->widget('bootstrap.widgets.TbGridView', array(
    'id' => 'Pengelola',
    'dataProvider' => $modelPengelola->search(),
    'type' => 'striped bordered condensed',
        //'htmlOptions' => array('style' => 'width:130%'),
	
    'columns' => array(
        array(
            'header' => 'Kode Lokasi',
            'value' => '$data->kode_png',
            
        ),
        array(
            'header' => 'Nama Lokasi',
            //'htmlOptions' => array('style' => 'text-align:center'),
            'value' => '$data->nama_png',
            
        ),
        
        //array(
//            'value' => 'CHtml::submitButton("Pilih",
//                array(
//                "kode_png"=>$data->kode_png,
//                "nama_png"=>$data->nama_png,                
//                "onClick"=>"PilihLokasi
//                ($(this).attr(\'kode_png\'),                
//                $(this).attr(\'nama_png\'))",

         array(
            'value' => 'CHtml::Button("Pilih",
                array("onClick" => "PilihLokasi(\'".$data->kode_png."#".
                $data->nama_png."\'
                )",
				"class"=>"btn btn-info",
				))',
            'type' => 'raw',
			'htmlOptions'=>array(
				'style'=>'text-align:center',
			),
        ),
    ),
));
?>

<?php
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>
